import java.lang.annotation.Annotation;
import java.lang.reflect.*;

public class StructInfo {
    public static void main(String[] args) {
        try {
            Class<?> rectangleClass = Class.forName("Rectangle");

            // 获取实现的接口信息
            Class<?>[] interfaces = rectangleClass.getInterfaces();
            for (Class<?> intf : interfaces) {
                System.out.println(intf);
            }

            // AnnotatedType[] annotatedInterfaces = rectangleClass.getAnnotatedInterfaces();
            // for (AnnotatedType annotatedInterface : annotatedInterfaces) {
            //     System.out.println(annotatedInterface);
            // }

            Class<?> superclass = rectangleClass.getSuperclass();
            System.out.println(superclass);

            Constructor<?>[] constructors = rectangleClass.getConstructors();
            for (Constructor<?> constructor : constructors) {
                System.out.println(constructor);
            }

            Constructor<?>[] declaredConstructors = rectangleClass.getDeclaredConstructors();
            for (Constructor<?> declaredConstructor : declaredConstructors) {
                System.out.println(declaredConstructor);
            }

            Method[] methods = rectangleClass.getMethods();
            for (Method method : methods) {
                System.out.println(method);
            }

            Method[] declaredMethods = rectangleClass.getDeclaredMethods();
            for (Method declaredMethod : declaredMethods) {
                System.out.println(declaredMethod);
            }

            Annotation[] annotations = rectangleClass.getAnnotations();
            for (Annotation annotation : annotations) {
                System.out.println(annotation);
            }

            Type genericSuperclass = rectangleClass.getGenericSuperclass();
            System.out.println(genericSuperclass);
            Type[] genericInterfaces = rectangleClass.getGenericInterfaces();
            for (Type genericInterface : genericInterfaces) {
                System.out.println(genericInterface);
            }

            Package aPackage = rectangleClass.getPackage();
            System.out.println(aPackage);

            Field[] fields = rectangleClass.getFields();
            for (Field field : fields) {
                System.out.println(field);
            }

            Field[] declaredFields = rectangleClass.getDeclaredFields();
            for (Field declaredField : declaredFields) {
                System.out.println(declaredField);
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
